package org.example.software.service.impl;

import org.example.software.entity.Paint;
import org.example.software.mapper.PaintMapper;
import org.example.software.service.PaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaintServiceImpl implements PaintService {
    @Autowired
    private PaintMapper paintMapper;

    @Override
    // 添加漆
    public boolean addPaint(Paint paint) {
        return paintMapper.insert(paint) > 0;
    }

    @Override
    // 删除漆
    public boolean deletePaintById(int id) {
        return paintMapper.deleteById(id) > 0;
    }

    @Override
    // 修改漆信息
    public boolean updatePaint(Paint paint) {
        return paintMapper.updateById(paint) > 0;
    }

    @Override
    // 根据 ID 查询漆
    public List<Paint> getPaintById(int id) {
        return paintMapper.getPaintById(id);
    }

    @Override
    // 根据 制造商 查询漆
    public List<Paint> getPaintByName(String manufacturerName) {
        return paintMapper.getPaintByName(manufacturerName);
    }

    @Override
    // 根据 颜色 查询漆
    public List<Paint> getPaintByColor(String color) {
        return paintMapper.getPaintByColor(color);
    }

    @Override
    // 根据 容量 查询漆
    public List<Paint> getPaintByCapacity(String capacity) {
        return paintMapper.getPaintByCapacity(capacity);
    }

    @Override
    //查找全部漆
    public List<Paint> getAllPaints(){
        List<Paint> paints =paintMapper.selectList(null);
        return paints;
    }
}
